import org.apache.zookeeper.KeeperException;
import org.apache.zookeeper.ZooKeeper;

import java.io.IOException;
import java.util.List;

/**
 * zookeeper 开始学习类
 *
 * @author yanbin
 * @version 2018/9/3 11:14
 **/
public class Simple {

	public static void main(String[] args) {

		try {
			// 1、指定IP和端口
			String connect = "10.19.37.151:2181";

			// 2、进行连接
			ZooKeeper zk = new ZooKeeper(connect, 2000, null);
			List<String> zooChildren = zk.getChildren("/", false);
			System.out.println("Znodes of '/': ");
			for (String child : zooChildren) {
				// print the children
				System.out.println(child);
			}
		} catch (IOException e) {
			e.printStackTrace();
		} catch (KeeperException e) {
			e.printStackTrace();
		} catch (InterruptedException e) {
			e.printStackTrace();
		}

	}

}
